import React from 'react'
import Myevents from "../utils/events"
import {useEffect} from "react" 
import Appgrand from './appgrand'
// 函数组件没有生命周期，可以通过hooks模拟
function Appson(props) {
  let fn = ()=>{
      console.log(props);
     props.sendfn("我是子组件的数据")
  }
  useEffect(()=>{
    Myevents.addListener("zhao",(data)=>{
        console.log(data);
    })
  },[]) // 当依赖项为空数组的时候，相当于类组件得componentDidmounted， 相当于vue的mounted
  return (
    <div>
      appsoan

        <button onClick={fn}>点我我给父组件传值</button>
        <Appgrand></Appgrand>
    </div>
  )
}

export default Appson